package com.doucat.support.component.start;

import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;

import java.util.ArrayList;

/**
 * -----------------------------------------------------------------
 * Copyright (C) 2021-2031, by tonly, All rights reserved.
 * -----------------------------------------------------------------
 * File: StarterProxy.java
 * Author: wangfy
 * Create: 2021/7/22 11:32
 */
public class StarterBuild {
    public static final int START_HOST_ACTIVITY=0;
    public static final int START_HOST_FRAGMENT=1;
    private Context context;
    private int type;
    private Bundle bundle;
    public StarterBuild setContext(Context context) {
        this.context = context;
        return this;
    }

    public StarterBuild setType(int type) {
        this.type = type;
        return this;
    }

    public StarterBuild setBundle(Bundle bundle) {
        this.bundle = bundle;
        return this;
    }

    public StarterBuild putString(String key,String value){
        bundle.putString(key,value);
        return this;
    }

    public StarterBuild putInt(String key,int value){
        bundle.putInt(key,value);
        return this;
    }

    public StarterBuild putParcelableArrayList(String key,ArrayList<? extends Parcelable> value){
        bundle.putParcelableArrayList(key,value);
        return this;
    }

    public StarterBuild putParcelable(String key,Parcelable value){
        bundle.putParcelable(key,value);
        return this;
    }

    public AbsStarter create(){
        AbsStarter starter=null;
        switch (type){
            case START_HOST_ACTIVITY:
                starter=new HostStarter(context);
                break;
            case START_HOST_FRAGMENT:
                starter=new FragmentStarter(context);
                break;
        }
        if(starter!=null){
            starter.setType(type);
            starter.setBundle(bundle);
        }
        return starter;
    }
}